package leetcode_1_200;

import java.util.Arrays;

public class LeeCode_189 {
    public static void main(String[] args) {
        rotate(new int[]{1,2,3,4,5,6,7}, 3);
    }
    private static void rotate(int[] nums, int k) {
        int len = nums.length;
        k %= len;
        int[] copy = Arrays.copyOfRange(nums, 0, len);
        for (int i = len - k, j = 0; i < len; i++, j++) {
            nums[j] = copy[i];
        }
        for (int i = 0, j = k; i < len - k; i++,j++) {
            nums[j] = copy[i];
        }
    }
}
